WOLF core
WOLF: A Modular Estimation Framework for Robotics
XXXXXXXXXXXXXXXXXXXXXXXXvoid(0)" frameborder="0" name="MSearchResults" id="MSearchResults">
node_base.h
Go to the documentation of this file.
1// WOLF - Copyright (C) 2020-2026
2// Institut de Robòtica i Informàtica Industrial, CSIC-UPC.
3// Authors: Joan Solà Ortega (jsola@iri.upc.edu) and
4// Joan Vallvé Navarro (jvallve@iri.upc.edu)
5// All rights reserved.
6//
7// This file is part of WOLF: http://www.iri.upc.edu/wolf
8// WOLF is free software: you can redistribute it and/or modify
9// it under the terms of the GNU General Public License version 3
10// as published by the Free Software Foundation.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program. If not, see <http://www.gnu.org/licenses/>.
19#pragma once
20
21// Wolf includes
22#include "core/common/wolf.h"
24
25namespace wolf
26{
73{
74 friend Problem;
75
76 private:
77 static unsigned int node_id_count_;
78
81 struct Serializer;
82
83 protected:
84 ProblemWPtr problem_ptr_;
85
86 unsigned int node_id_;
87 std::string node_category_;
88 std::string node_type_;
89 std::string node_name_;
91
93
96 virtual void setProblem(ProblemPtr _prob_ptr);
97
98 public:
105 NodeBase(const std::string& _category, const std::string& _type = "Undefined", const std::string& _name = "");
106
109 virtual ~NodeBase() = default;
110
113 unsigned int nodeId() const;
114
117 std::string getCategory() const;
118
121 std::string getType() const;
122
125 std::string getName() const;
126
129 bool isRemoving() const;
130
133 virtual bool hasChildren() const = 0;
134
137 void setType(const std::string& _type);
138
141 void setName(const std::string& _name);
142
145 ProblemConstPtr getProblem() const;
146
149 ProblemPtr getProblem();
150};
151
152} // namespace wolf
153
154#include <iostream>
155
156namespace wolf
157{
158inline NodeBase::NodeBase(const std::string& _category, const std::string& _type, const std::string& _name)
159 : problem_ptr_(), // nullptr
160 node_id_(++node_id_count_),
161 node_category_(_category),
162 node_type_(_type),
163 node_name_(_name),
164 is_removing_(false)
165{
166 //
167}
168
169inline unsigned int NodeBase::nodeId() const
170{
171 return node_id_;
172}
173
174inline std::string NodeBase::getCategory() const
175{
176 return node_category_;
177}
178
179inline std::string NodeBase::getType() const
180{
181 return node_type_;
182}
183
184inline std::string NodeBase::getName() const
185{
186 return node_name_;
187}
188
189inline bool NodeBase::isRemoving() const
190{
191 return is_removing_;
192}
193
194inline void NodeBase::setType(const std::string& _type)
195{
196 node_type_ = _type;
197}
198
199inline void NodeBase::setName(const std::string& _name)
200{
201 node_name_ = _name;
202}
203
204inline ProblemConstPtr NodeBase::getProblem() const
205{
206 return problem_ptr_.lock();
207}
208
209inline ProblemPtr NodeBase::getProblem()
210{
211 return problem_ptr_.lock();
212}
213
214inline void NodeBase::setProblem(ProblemPtr _prob_ptr)
215{
216 problem_ptr_ = _prob_ptr;
217}
218
219} // namespace wolf
Base class for Nodes.
Definition: node_base.h:73
std::string node_type_
Type or subcategory of node (derived class name: "SensorOdom2d", etc)
Definition: node_base.h:88
unsigned int node_id_
Node id. It is unique over the whole Wolf Tree.
Definition: node_base.h:86
bool isRemoving() const
Returns whether the node is being removed.
Definition: node_base.h:189
std::string node_category_
Text label identifying the category of node ("SENSOR", "FEATURE", etc)
Definition: node_base.h:87
std::string getType() const
Returns the type (subcategory) of the node.
Definition: node_base.h:179
bool is_removing_
A flag for safely removing nodes from the Wolf tree. See remove().
Definition: node_base.h:92
void setName(const std::string &_name)
Sets the name of the node.
Definition: node_base.h:199
std::string getName() const
Returns the name of the node.
Definition: node_base.h:184
unsigned int nodeId() const
Returns the node id, unique over the whole Wolf tree.
Definition: node_base.h:169
std::string node_name_
Definition: node_base.h:89
ProblemWPtr problem_ptr_
Problem the node belongs to.
Definition: node_base.h:84
virtual ~NodeBase()=default
Destructor.
std::string getCategory() const
Returns the category of the node.
Definition: node_base.h:174
virtual void setProblem(ProblemPtr _prob_ptr)
Sets the problem the node belongs to.
Definition: node_base.h:214
void setType(const std::string &_type)
Sets the type (subcategory) of the node.
Definition: node_base.h:194
NodeBase(const std::string &_category, const std::string &_type="Undefined", const std::string &_name="")
Constructor.
Definition: node_base.h:158
ProblemConstPtr getProblem() const
Returns the problem the node belongs to.
Definition: node_base.h:204
virtual bool hasChildren() const =0
Returns whether the node has children in the Wolf tree.
Wolf problem: root of the wolf tree (hardware, trajectory and map). It manages the motion providers,...
Definition: problem.h:66
Definition: capture_base.h:23